package com.sync.syncmasterdata;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sync.syncmasterdata.customer.controller.CusSyncController;
import com.sync.syncmasterdata.customer.pojo.CrmCustomer;
import com.sync.syncmasterdata.customer.pojo.OACustomer;
import com.sync.syncmasterdata.customer.pojo.bip.CustomerAssign;
import com.sync.syncmasterdata.customer.pojo.bip.CustomerForBip;
import com.sync.syncmasterdata.customer.service.impl.BipCustomerServiceImpl;
import com.sync.syncmasterdata.customer.service.impl.SyncServiceImpl;
import com.sync.syncmasterdata.defdoc.domain.BrandForBipDTO;
import com.sync.syncmasterdata.defdoc.domain.DefDocDTO;
import com.sync.syncmasterdata.product.pojo.bip.ProductForBip;
import com.sync.syncmasterdata.product.pojo.bip.ProductProdForBip;
import com.sync.syncmasterdata.product.pojo.bip.ProductStockForBip;
import com.sync.syncmasterdata.pubdomain.BipResponse;
import com.sync.syncmasterdata.util.BipRequestUtil;
import com.sync.syncmasterdata.util.NormalUtil;
import com.sync.syncmasterdata.vendor.controller.VendorSyncController;
import com.sync.syncmasterdata.vendor.pojo.bip.SupplierForBip;
import com.sync.syncmasterdata.vendor.pojo.bip.SupplierForBipUpdate;
import com.sync.syncmasterdata.vendor.service.convert.OAToBipForVendor;
import com.sync.syncmasterdata.vendor.service.impl.BipSupplierServiceImpl;
import lombok.extern.slf4j.Slf4j;
import nccloud.open.api.auto.token.itf.IAPIUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.*;


@SpringBootTest
@Slf4j
class SyncMasterDataApplicationTestsBIP2 {
    @Autowired
    private VendorSyncController vendorSyncController;
    @Autowired
    private BipCustomerServiceImpl bipCustomerService;
    @Autowired
    private BipSupplierServiceImpl bipSupplierService;
    @Autowired
    private ObjectMapper objectMapper;

    @Autowired
    private OAToBipForVendor oaToBipForVendor;

    @Autowired
    private SyncServiceImpl syncService;

    @Test
    void vendorTest() {
        try {
            String req = "{\"id\":\"36634\",\"kehumc\":\"痞子姚的供应商33\",\"zuizhongkehu\":null,\"kehulx\":null,\"qita\":null,\"sheng\":null,\"shi\":null,\"kehulb\":1,\"shifouyzz\":0,\"huobilx\":0,\"suozaisf\":0,\"suozaics\":30,\"kehuzt\":0,\"kaihuh\":\"农村商业银行\",\"kaihuzh\":\"成都农商银行彭州致和支行\",\"zhanghao\":\"222233333333\",\"lianhangh\":\"314651022212\",\"crmid\":null,\"U8kehubm\":null,\"u8VonderCode\":null}";
            OACustomer oaCustomer = objectMapper.readValue(req, OACustomer.class);
            vendorSyncController.oaVendorPushForAdd(oaCustomer);

        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    void customerTest() {
        CrmCustomer crmCustomer = syncService.getCrmAccount("8721b87f-9a5b-f011-8ccb-80e25c682137");
//        crmCustomer.setNew_erp_num("012207001");
//        cusSyncController.handleBipCustomerFromCrm(crmCustomer, "add");
    }

    /**
     * 修改客户测试
     */
    @Test
    void customerEditTest() {
        CrmCustomer crmCustomer = new CrmCustomer();
        crmCustomer.setNew_erp_num("123");
        crmCustomer.setAccountid("123");
        crmCustomer.setName("痞子姚客户更新2");
        crmCustomer.setNew_num("B0001");
        crmCustomer.setNew_type(1);
        bipCustomerService.handleUpdateCustomerData(crmCustomer);
    }

    /**
     * 修改供应商测试
     */
    @Test
    void supplierEditTest() {
        OACustomer oaCustomer = new OACustomer();
        oaCustomer.setId("36634");
        oaCustomer.setKehumc("痞子姚的供应商66");
        oaCustomer.setU8VonderCode("N33012193");
        oaCustomer.setKehuzt(0); // 启用状态
        oaCustomer.setSuozaics(101); // 假设对应分类


        // 执行更新方法
        bipSupplierService.updateSupplier(oaCustomer);
    }



}
